package com.tjn.methods;

/**
 * @author 陶镓妮
 * @version 1.0
 */
public class ThreadMethodExercise {
    public static void main(String[] args) throws InterruptedException {
        T1 t1 = new T1();
        Thread thread = new Thread(t1);
        for (int i = 0; i < 10; i++) {
            System.out.println("hi" + i);
            Thread.sleep(1000);
            if(i ==5){
                thread.start();
                thread.join();
            }
        }
    }
}
class T1 implements Runnable{
    @Override
    public void run() {
        int count = 0;
        for (int i = 0; i < 10; i++) {
            System.out.println("hello" + (++count));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}